package com.pacyki.adapters;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.TextView;

import com.pacyki.datamodel.PostCardText;
import com.pacyki.datamodel.SectionBackground;
import com.pacyki.gcards.R;

public class SectionsAdapter extends BaseAdapter {
	private Context mContext;
	private LayoutInflater mInflater;
	private ArrayList<SectionBackground> mItems;
	
	public SectionsAdapter(Context context, ArrayList<SectionBackground> items) {
		mContext = context;
		mItems = items;
		mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public int getCount() {
		return mItems.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		PostCardTextHolder holder;
		
		if (null == convertView){
			convertView = mInflater.inflate(R.layout.section_background_item, null, false);
			holder = new PostCardTextHolder();
			holder.text = (TextView) convertView.findViewById(R.id.categoryTextView);
			convertView.setTag(holder);
		} else{
			holder = (PostCardTextHolder) convertView.getTag();
		}

		SectionBackground curItem = mItems.get(position);
		holder.text.setText(curItem.getName());
		
		return convertView;
	}
	
	public class PostCardTextHolder {
		public TextView text;
	}
}
